package org.fast.develop.logicflow.rest.util;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @author apple
 */
public class VoUtil {

	public static <T> ResponseEntity<T> getSuccessResult() {
		Map newResult = new HashMap();
		newResult.put("status", "0");
		newResult.put("msg", "操作成功");
		return new ResponseEntity(newResult, HttpStatus.OK);
	}

	public static <T> ResponseEntity<T> setSuccessResult(T result) {

		if (Objects.nonNull(result)) {
			return new ResponseEntity(result, HttpStatus.OK);
		}
		else {
			Map newResult = new HashMap();
			newResult.put("status", "0");
			newResult.put("msg", "操作成功");
			return new ResponseEntity(newResult, HttpStatus.OK);
		}

	}

}
